// app.js
App({
  globalData: {
    appid: 'wx0f766fe61ae626bb',
		share: false, // 分享默认为false
		isScan: false,
    height: 0,
    user: null,
    userInfo: null,
    // 页面初始化时的参数
    launch_options: {},
    scanParams: {}, // 存储扫码参数
  },
  onLaunch(launch_options) {
    const that = this;
    console.log('launch_options', launch_options);

    // 获取系统信息
    this.globalData.system = wx.getWindowInfo()
    // 获取胶囊信息
    this.globalData.capsule = wx.getMenuButtonBoundingClientRect()

    // 判断是否由分享进入小程序
		if (launch_options.scene == 1007 || launch_options.scene == 1008) {
			this.globalData.share = true
		} else {
			this.globalData.share = false
    };
    
    // 这里的 scene 是扫码时传递的参数，判断是否为扫码进入
    if (launch_options.scene === 1047 || launch_options.scene === 1048) {
      // 是通过扫码进入小程序
      const options = wx.getLaunchOptionsSync();
      this.globalData.isScan = true;
      this.globalData.scanParams = options.query; // 保存扫码传递的参数
    } else {
      // 不是扫码进入
      this.globalData.isScan = false;
      this.globalData.scanParams = {}
    }

    //获取设备顶部窗口的高度（不同设备窗口高度不一样，根据这个来设置自定义导航栏的高度
    wx.getSystemInfo({
      success: (res) => {
        this.globalData.height = res.statusBarHeight
      }
    })

		//保存接收到的参数
		this.globalData.launch_options = launch_options;


  },

  onShow:function (res) {
    // console.log('app-onShow', res);
    const shareTicket = res.shareTicket;
    this.globalData.shareTicket = shareTicket;
  }

})